home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / Dir / dir.gcview < prev    next >
Text File  |  1999-04-21  |  7KB  |  312 lines

  1. G4C  
  2.  
  3. ; dir.gcview - by dck January 1999
  4. ; A GUI for GCView - gcview should be in guis:c/gcview
  5.  
  6.  
  7. WINBIG 180 15 200 166  "GCView 1.0 by dck@hol.gr"
  8. WinType 11110001
  9.  
  10. xOnLoad
  11.     ; start gcview
  12.     ifexists port ~gcview
  13.        run 'guis:ext/view/gcview'
  14.        wait port gcview 50
  15.        if $$retcode > 0
  16.           EZReq "Guis:c/GCView not found!" "OK" ""
  17.           guiquit #this
  18.           stop
  19.        endif
  20.     endif
  21.  
  22.     setgad #this 33 hide
  23.     mode   = FILES
  24.     gosub #this FileMode
  25.     guiopen #this
  26.  
  27. xOnClose
  28.     guiquit #this
  29.     call gcview quit force
  30.  
  31. xRoutine FileMode                        ; change gui to file list
  32.     setgad #this 1/13  HIDE
  33.     setgad #this 21/25 SHOW
  34.     redraw #this
  35.  
  36. xRoutine ConvertMode                    ; change gui to options gadgets
  37.     setgad #this 1/13  SHOW
  38.     setgad #this 21/25 HIDE
  39.     redraw #this
  40.  
  41. XCYCLER 0 0 200 14  "" mode        ; cycler to choose the mode    
  42.     cstr "Choose/Add Files" FILES
  43.     Cstr "Converting Options" CONVERT
  44.     if $mode = CONVERT
  45.        gosub #this ConvertMode
  46.     else
  47.        gosub #this FileMode
  48.     endif
  49.  
  50. ;------------------ PRETTY OBVIOUS OPTIONS GADGETS
  51.  
  52. ; XCYCLER 70 15 125 14  Format format
  53. ;    GadID 1
  54. ;    cstr ILBM ILBM
  55. ;    cstr GIF  GIF
  56. ;    cstr JPEG JPEG
  57. ;    cstr PCX  PCX
  58. ;    cstr PostScript Postscript
  59. ;    cstr RGB-Raw   RGB-Raw
  60.  
  61.  
  62. ; XCYCLER 70 30 125 14  Colors colors
  63. ;    GadId 2
  64. ;    cstr Default ""
  65. ;    cstr 16      16
  66. ;    cstr 32      32
  67. ;    cstr 128     128
  68. ;    cstr 256     256
  69. ;    cstr 2       2
  70. ;    cstr 4       4
  71. ;    cstr 8       8
  72.  
  73. ; XCYCLER 70 45 125 14  Type bw
  74. ;    GadId 3
  75. ;    cstr Default    ""
  76. ;    cstr GRAYSCALE  GRAYSCALE
  77. ;    cstr BW         BW
  78. ;    cstr INVERT     INVERS
  79. ;    cstr "NO Red"   NORED
  80. ;    cstr "NO Green" NOGREEN
  81. ;    cstr "NO Blue"  NOBLUE
  82.  
  83. ; XCYCLER 70 60 125 14  Flip flip
  84. ;    gadid 11
  85. ;    Cstr None  ""
  86. ;    cstr "Flip X" FLIPX
  87. ;    cstr "Filp Y" FLIPY
  88. ;    cstr "Flip XY" "FLIPX FLIPY"
  89.  
  90. ; XCYCLER 70 75 125 14  Rotate rot
  91. ;    gadid 12
  92. ;    cstr None ""     
  93. ;    cstr "90 Left"   ROTATELEFT
  94. ;    cstr "90 Right"  ROTATERIGHT
  95.  
  96. ;    ; NOT IMPLEMENTED YET
  97. ;    ; slider contrast CONTRAST 0-100
  98. ;    ; slider brightness BRIGHTNESS 0-255
  99.  
  100. ;---- Size
  101.  
  102. ; XCYCLER 70 90 125 14  Size size
  103. ;    gadid 4
  104. ;    cstr Same    ""
  105. ;    cstr BOXFIT  BOXFIT
  106. ;    cstr SIZE    SIZE
  107. ;    if $size = NONE
  108. ;       setgad #this 5 OFF
  109. ;       setgad #this 6 OFF
  110. ;    else
  111. ;       setgad #this 5 ON
  112. ;       setgad #this 6 ON
  113. ;    endif
  114.  
  115. ; ; -- Size textin gadgets
  116. ; XTEXTIN 70 105 61 14  "" x 320 10
  117. ;    gadid 5
  118. ;    SetGad #this 6 ON
  119.  
  120. ; XTEXTIN 135 105 59 14  "" y 250 10
  121. ;    gadid 6
  122.  
  123. ; -------------------- Status Boxes
  124.  
  125.  
  126. TEXT 5 112 40 10  "Status:" 20 NOBOX
  127.     gadid 7
  128.  
  129. TEXT 4 123 190 12  "No Files" 130 BOX
  130.     GadID 8
  131.  
  132. Gauge 4 136 190 12 IN BUTTON 3 0 0
  133.     gadid 13
  134.  
  135.  
  136. ;--------------------- LISTVIEW SHOWING FILES TO CONVERT
  137.  
  138. XLISTVIEW 0 15 198 132  "" cfile "" 10 MULTI
  139.     gadid 21
  140.  
  141. XBUTTON 0 150 50 14  View
  142.     gadid 25
  143.     lvuse #this 21
  144.     lvmulti first
  145.     while $$lv.line > ""
  146.        *RUNMODE  = 'run >nil:'
  147.        *FILENAME = $file
  148.        gosub viewfile.g ViewFile
  149.        lvmulti next
  150.     endwhile
  151.  
  152. XBUTTON 50 150 50 14  Add            ; add files selected from dir.gc
  153.     gadid 22
  154.     gui = $$lv.gui
  155.     id  = $$lv.id
  156.     if $$lv.mode != DIR
  157.         ezreq 'Please choose files from\na Directory Listview!' Ok ''
  158.         stop
  159.     endif
  160.     lvmulti first
  161.     var = \$$$lv.var
  162.     while $$lv.line > ""
  163.         if $var H= 'FORM????ILBM'    ; IFF
  164.         or $var H= "??????JFIF"        ; JPEG
  165.         or $var H= "ÿØÿÄ"                ; JPEG
  166.         or $var H= "GIF"                ; GIF
  167.         or $var H= "?PNG"                ; PNG
  168.            lvuse   #this 21
  169.            lvadd   $var
  170.            lvuse   $gui $id
  171.         endif
  172.        lvmulti off
  173.        lvmulti next
  174.     endwhile
  175.  
  176. XBUTTON 100 150 50 14  Del           ; delete selected files
  177.     gadid 23
  178.     lvuse #this 21
  179.     lvmulti first
  180.     while $$lv.line > ""
  181.        lvdel -1
  182.        lvmulti first        ; use first again since last first was deleted
  183.     endwhile
  184.  
  185. XBUTTON 150 150 50 14  Clr
  186.     gadid 24
  187.     lvuse #this 21
  188.     lvclear
  189.  
  190.  
  191. ; -------------------------------------------------------------------
  192. ;-------------------- Abort
  193. ; -------------------------------------------------------------------
  194.  
  195. XBUTTON 100 150 95 14  Abort 
  196.     gadid 9
  197.     stopflag = 1
  198.  
  199.  
  200. ; -------------------------------------------------------------------
  201. ;-------------------- Start converting
  202. ; -------------------------------------------------------------------
  203.  
  204. XBUTTON 5 150 95 14  "Convert"
  205.     gadid 10
  206.     gadfont #screen 8 010
  207.  
  208.     ; load my palette
  209.     call gcview load SQ0:Data/Art/PALETTE/Palette-Grn16 mypal palette
  210.  
  211.    ; create a palette
  212.    call gcview create picpal 0 0 8
  213.  
  214.     lvuse #this 21
  215.     lvmulti all
  216.     count = 0
  217.     stopflag = 0
  218.     total = $$lv.tot
  219.     update #this 13 0 ; gauge
  220.     lvmulti first
  221.  
  222.     gosub #this nextfile
  223.  
  224.  
  225. ; -------------------------------------------------------------------
  226. ; ---------------------- CALLED for each file
  227. ; -------------------------------------------------------------------
  228.  
  229. XLISTVIEW 0 15 198 132  "" com "" 0 MULTI     ; used to construct batch file
  230.     gadid 33
  231.  
  232. xROUTINE nextfile
  233.  
  234.     update #this 13 $(($count / $total) * 100)    ; gauge
  235.  
  236.     lvuse #this 21
  237.     if $$lv.line > ""
  238.     and $stopflag = 0
  239.  
  240.        update #this 7 Converting:
  241.        update #this 8 'File: $cfile'
  242.  
  243.  
  244.         lvuse #this 33
  245.         lvclear
  246.         lvadd 'GCVU'
  247.         lvadd 'load $cfile pic'
  248.  
  249.        ; set picture palette & overlay mine
  250.        lvadd 'set palette picpal pic'
  251.        lvadd 'set palette picpal mypal'
  252.  
  253.         lvadd 'rexx Gui4Cli "update dir.gcview 8 Remapping.."'
  254.        lvadd 'remap pic picpal'
  255.         lvadd 'set palette pic picpal'
  256.  
  257.                 ; DELETE OLD FILE !!!!! REMOVE THIS ###### !!!!!
  258.                 ; update #this 8 'Deleting old file..'
  259.                 ; action delete $cfile noreq    ; No pattern matching!!
  260.  
  261.        extract cfile ext fext
  262.        if $fext == .iff
  263.           newext = '2.iff'
  264.        else
  265.           newext = '.iff'
  266.        endif
  267.  
  268.        searchvar cfile $fext cs first
  269.        c = $$search.pos
  270.        extract cfile unquote cfile
  271.        cfile[$c] = $newext
  272.  
  273.         lvadd 'rexx Gui4Cli "update dir.gcview 8 Saving.."'
  274.        lvadd 'set mode pic 0x00029004'
  275.        lvadd 'save pic $cfile'
  276.        lvadd 'unload pic'
  277.  
  278.         ++count    ; update gauge
  279.  
  280.         ; notify us when finished
  281.         lvadd 'rexx Gui4Cli "gosub dir.gcview nextfile"'
  282.  
  283.         ; execute the listview file
  284.         lvsave T:gcCom
  285.         call gcview execute T:gcCom
  286.  
  287.         lvuse #this 21
  288.         lvmulti off
  289.         lvmulti next
  290.  
  291.     else
  292.  
  293.         call gcview unload picpal
  294.         call gcview unload mypal
  295.         if $stopflag = 1
  296.             update #this 7 Aborted:
  297.         else
  298.             update #this 7 Status:
  299.         endif
  300.        update #this 8 'Converted $count files'
  301.  
  302.     endif
  303.  
  304. ; -------------------------------------------------------------------
  305. ; ERROR --- This is where we'll end up if anything goes wrong..
  306. ; -------------------------------------------------------------------
  307.  
  308. xOnFail
  309.     EZReq  "An error occured.\nClick on Convert to continue." "OK" ""
  310.  
  311.  
  312.